<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="用户名称" prop="nickName">
        <el-input
          v-model="queryParams.nickName"
          clearable
          placeholder="请输入用户名称"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="同意状态" prop="state">
        <el-select v-model="queryParams.state" placeholder="请选择状态" clearable>
          <el-option
            v-for="item in dict.type.meeting_invite_state"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <el-form-item label="签到状态" prop="isAttendance">
          <el-select v-model="queryParams.isAttendance" placeholder="请选择签到状态" clearable>
            <el-option
              v-for="item in dict.type.is_check_in"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['viewuser:detailed:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="detailedList">
      <el-table-column type="index" width="55" label="序号" align="center"/>
      <el-table-column label="用户名称" align="center" prop="nickName"/>
      <el-table-column label="手机号" align="center" prop="phonenumber"/>
      <el-table-column label="性别" align="center" prop="sex">
        <template slot-scope="scope">
          <span> {{ scope.row.sex === 0 ? '男' : scope.row.sex === 1 ? '女' : '未知' }} </span>
        </template>
      </el-table-column>
      <el-table-column label="部门" align="center" prop="deptName"/>
      <el-table-column label="岗位" align="center" prop="postName"/>
      <el-table-column label="同意状态" align="center" prop="state">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.meeting_invite_state" :value="scope.row.state"/>
        </template>
      </el-table-column>
      <el-table-column label="拒绝理由" align="center" prop="reason">
        <template slot-scope="scope">
          <span> {{ scope.row.reason == null ? '无' : scope.row.reason }} </span>
        </template>
      </el-table-column>
      <el-table-column label="签到状态" align="center" prop="isAttendance">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.is_check_in" :value="scope.row.isAttendance"/>
        </template>
      </el-table-column>
      <el-table-column label="操作时间" align="center" prop="operateTime">
        <template slot-scope="scope">
          <span> {{ scope.row.operateTime == null ? '无' : parseTime(scope.row.operateTime, '{y}-{m}-{d} {h}:{i}') }} </span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {listDetailed} from "@/api/viewuser/detailed"
import {parseTime} from "@/utils/ruoyi";

export default {
  name: "Detailed",
  dicts: ['meeting_invite_state','is_check_in'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 参会人员表格数据
      detailedList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      par: undefined
    }
  },
  created() {
    this.par = this.$router.currentRoute.params.meetingName
    this.getList()
  },
  methods: {
    parseTime,
    /** 查询参会人员列表 */
    getList() {
      this.loading = true
      if (this.par === undefined) {
        this.$router.push({name: "Ours"})
        return false
      }
      this.queryParams.meetingName = this.$router.currentRoute.params.meetingName
      listDetailed(this.queryParams).then(response => {
        this.detailedList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        inviterId: null,
        userId: null,
        meetingName: null,
        startTime: null,
        startDate: null,
        password: null,
        id: null,
        state: null,
        reason: null,
        meetingLaunchDate: null,
        isAttendance: null,
        attendanceTime: null,
        endTime: null
      }
      this.resetForm("form")
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.queryParams = {}
      this.handleQuery()
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('viewuser/detailed/export', {
        ...this.queryParams
      }, `detailed_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
